<template>
  <div class="counter-warp">
    <div class="history-search">
      <div class="history-search-edit">
        <input type="text" class="history-search-edit-input" :focus="inputfocus" placeholder="输入一切不想做的，例如不做家务"  v-model="jiTextValue"/>
        <div class="history-search-title">
          忌
        </div>
      </div>
      <div class="area-title">
        最“忌”榜单
      </div>
      <div class="history-search-area">
        <ul class="history-search-list">
          <li v-for="(item, index) in jiList" :key="item.id" @click="selJi($event, item)" :itemt="item">{{item}}</li>
        </ul>
      </div>
      <div class="history-btn-box">
        <a class="empty-confirm" @click="goYi">填上一个儿 ←</a>
        <a class="empty-next" @click="confirmJi">确认</a>
      </div>
    </div>
    <!-- <p>Vuex counter：{{ count }}</p>
    <p>
      <button @click="increment">+</button>
      <button @click="decrement">-</button>
    </p>

    <a href="/pages/index/main" class="home">去往首页</a> -->
  </div>
</template>

<script>
// Use Vuex
import store from "@/store";

export default {
  computed: {
    jiText () {
      return store.state.jiText;
    },
    yiText () {
      return store.state.yiText;
    },
    jiList () {
      return store.state.jiList;
    }
  },
  data () {
    return {
      jiTextValue: "",
      inputfocus: true
    };
  },
  mounted () {
    this.jiTextValue = this.jiText;
  },
  config: {
    backgroundColor: "#dedacd"
  },
  created (params) {
    console.log(params);
  },
  onLoad (params) {
    console.log(params);
    console.log(this.count);
  },
  methods: {
    goYi () {
      const url = "/pages/yi/main?yiText=" + this.yiText;
      store.commit("jiText", this.jiTextValue);
      wx.redirectTo({ url });
    },
    confirmJi () {
      console.log(this.yiText);
      store.commit("jiText", this.jiTextValue);
      // wx.redirectTo({ url: "/pages/index/main" });
      wx.navigateBack({
        delta: 0
      });
    },
    selJi (param, text) {
      this.jiTextValue = text;
    }
    // increment () {
    //   store.commit("increment");
    // },
    // decrement () {
    //   store.commit("decrement");
    // }
  }
};
</script>
<style>
.area-title {
  height: 85rpx;
  line-height: 85rpx;
  padding-left: 30rpx;
  background-color: #efeff4;
  font-size: 28rpx;
  color: #888888;
  text-align: left;
}
.history-search {
  background-color: #efeff4;
  padding-top: 30rpx;
}
.history-search-edit {
  height: 90rpx;
  line-height: 90rpx;
  padding-right: 30rpx;
  background-color: #fff;
  border-top: 1rpx solid #eee;
  position: relative;
  font-size: 34rpx;
}
.history-search-edit-input {
  height: 90rpx;
  line-height: 90rpx;
  width: 620rpx;
  float: right;
  text-align: left;
  font-size: 34rpx;
}
::-webkit-input-placeholder {
  /* WebKit browsers */
  color: #b2b2b2;
}
:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  color: #b2b2b2;
}
::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  color: #b2b2b2;
}
:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  color: #b2b2b2;
}
.history-search-title {
  width: 95rpx;
  height: 90rpx;
  text-align: center;
  line-height: 90rpx;
  position: absolute;
  left: 0;
  top: 0;
}

.history-search-area {
  background: #fff;
  overflow: hidden;
  padding-left: 30rpx;
}

.history-search-area .history-search-list {
  overflow: hidden;
}

.history-search-area .history-search-list li {
  height: 90rpx;
  line-height: 90rpx;
  font-size: 28rpx;
  border-bottom: 1rpx solid #eee;
  color: #666;
  padding-left: 30rpx;
}

.history-search-area .history-search-list li a {
  text-decoration: none;
  color: #333;
  padding-left: 0.35rem;
  display: block;
}

.history-btn-box {
  padding: 60rpx 0;
  background-color: #efeff4;
  font-size: 0;
  text-align: center;
}
.history-btn-box a {
  height: 86rpx;
  line-height: 86rpx;
  width: 333rpx;
  border: 1rpx solid #d6d5d6;
  border-radius: 10rpx;
  display: inline-block;
  font-size: 36rpx;
  color: #000;
  background-color: #fff;
  text-align: center;
  margin: 0 10rpx;
}

.history-btn-box a.empty-next {
  border: 1rpx solid #e5a900;
  color: #fff;
  background-color: #e5a900;
}

.history-search-area .empty-history {
  width: 3.3rem;
  height: 0.7rem;
  line-height: 0.7rem;
  margin: 0.3rem auto;
  border: 1px solid #ccc;
  display: block;
  text-align: center;
  background: #f5f5f5;
  font-size: 0.24rem;
}
</style>
